package com.lagou.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

//指定是对消费方还是提供方进行拦截
@Activate(group = {CommonConstants.CONSUMER, CommonConstants.PROVIDER})
public class DubboFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long start = System.currentTimeMillis();
        try {
            return invoker.invoke(invocation);
        } finally {
            long end = System.currentTimeMillis();
            System.out.println("耗时时间：" + (end - start) + "毫秒");
        }
    }

}
